package SessionFactory;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class Config {
	private final static String cfg = "mybatis-config.xml";
	
	public static SqlSession getSession(){
		try {
			InputStream inputStream = Resources.getResourceAsStream(cfg);
			SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
			return sqlSessionFactory.openSession();
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
}
